#!/usr/bin/env node
//输出 
// process.stdout.write('请输入用名：')
//输入
// process.stdin.on('data',chunk=>{
//     console.log(chunk.toString())
// })

let arr = [
    {
        question:'请输入用户名：'
    },
    {
        question:'请输入密码：'
    },
    {
        question:'请输入邮箱账号：'
    },
]

module.exports = (questions=arr)=>{
    let obj = {

    }
    let index = 0
    process.stdout.write(questions[index].question)
    process.stdin.on('data',chunk=>{
        
        if(index===0){
            obj.username = chunk.toString().trim()
            process.stdout.write(questions[index+1].question)
        }else if( index === 1){
            obj.password = chunk.toString().trim()
            process.stdout.write(questions[index+1].question)
        }else if( index === 2){
            obj.email = chunk.toString().trim()
            console.log(obj)
            process.exit()
        }
    
        index += 1
    })
}